/**
 * 20220112：废弃
 */
let THREE=require('three');

/**
 * 拖动配置基类
 * @param values {object}
 threshold:0.1 拾取阈值
 dynamicReferencePlane:false 拖动过程中是否更新参考面为当前状态
 rangeSq:10000 拖动范围（平方）具体配置实现
 */
export default class DragConfig{
    constructor(values={}){
        console.log('this class is deprecated now!');
        this._values=values;
        this._init();
    }

    /**
     * 获取配置类型
     * @returns {string}
     */
    get type(){
        return 'drag-config';
    }

    /**
     * 获取ID
     * @returns {null|string}
     */
    get uuid(){
        return this._uuid;
    }

    /**
     * 获取约束
     * @returns {*|null}
     */
    get limit(){
        return this._limit;
    }

    /**
     * 设置拖动的约束
     * @param limit
     */
    set limit(limit){
        this._limit=limit;
    }

    /**
     * 将当前的约束设为记忆点
     */
    get remember(){
        this._baseLimit=this._limit;
    }

    /**
     * 恢复到记忆点约束
     */
    get recall(){
        this._limit=this._baseLimit;
    }

    //-----------------------------------------------------------------------------------------------

    get threshold(){
        return this._threshold;
    }
    set threshold(number){
        this._threshold=number;
    }
    get dynamicReferencePlane(){
        return this._dynamicReferencePlane;
    }
    set dynamicReferencePlane(bol){
        this._dynamicReferencePlane=bol;
    }
    get rangeSq(){
        return this._rangeSq;
    }
    set rangeSq(number){
        this._rangeSq=number;
    }

    //-----------------------------------------------------------------------------------------------

    /**
     * 检测对象类型是否符合当前配置
     * @param object
     * @returns {boolean}
     */
    checkType(object){
        console.warn('needs override this method!');
        return false;
    }

    /**
     * 当前配置类型对象的对比函数
     * @param a
     * @param b
     * @returns {boolean}
     */
    compare(a,b){
        console.warn('needs override this method!');
        return true;
    }

    /**
     * 检测对象是否拾取成功
     * @param object
     * @param pointer
     * @param camera
     * @param rect
     * @returns {boolean}
     */
    intersectObject(object,pointer,camera,rect){
        console.warn('needs override this method!');
        return false;
    }

    /**
     * 设置拖动开始状态
     * @param interset
     * @param object
     * @param plane
     * @param offset
     * @param camera
     * @param rect
     */
    setDragStart(interset,object,plane,offset,camera,rect){
        console.warn('needs override this method!');
    }

    /**
     * 设置拖动过程状态
     */
    setDragMove(){
        console.warn('needs override this method!');
    }

    /**
     * 销毁
     */
    dispose(){
        this._limit.dispose();
        this._threshold=null;
        this._dynamicReferencePlane=null;
        this._rangeSq=null;
        this._uuid=null;
        this._limit=null;
        this._baseLimit=null;
    }

    /**
     * 对象的拖动行为
     * @param object
     * @param wldPos
     * @param callback
     * @param camera
     * @private
     */
    _moveObject(object, wldPos,callback,camera){}

    _init(){
        this._initVariable();
    }
    _initVariable(){
        this._threshold=this._values.threshold||0.1;
        this._dynamicReferencePlane=this._values.dynamicReferencePlane||false;
        this._rangeSq=this._values.rangeSq||10000;

        this._uuid=THREE.Math.generateUUID();
        this._limit=null;
        this._baseLimit=null;
    }
}